﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LIMS.Common
{

    /// <summary>
    /// 公共分页，简要封装
    /// </summary>
    /// <typeparam name="TSource">数据源约束类型，具有公共无参构造方法</typeparam>
    public class CommonPager<TSource> where TSource : class
    {
        /// <summary>
        /// 获取指定类型、指定页的数据
        /// </summary>
        /// <param name="source">指定的数据源</param>
        /// <param name="pageSize">每页显示的数据项数</param>
        /// <param name="pageIndex">页码索引</param>
        /// <returns>返回分页后的数据</returns>
        public static IEnumerable<TSource> GetTSourceByPager(IEnumerable<TSource> source, Int32 pageSize, Int32 pageIndex)
        {
            return source.Skip(pageSize * (pageIndex - 1)).Take(pageSize);
        }
    }

}
